/*
 * Copyright (C) 2020 1km Group Holding Limited
 */

#ifndef __DM556_DRIVER_H
#define __DM556_DRIVER_H

#ifdef __cplusplus
extern "C" {
#endif

#include "bsp.h"
#include "board.h"

typedef enum {
    PROFILE_POSITION = 1,
	PROFILE_VELOCITY = 3,
	HOMING_MODE = 6
} dm556_operate_mode_t;

typedef enum {
    RESET_CMD = 0,
	DRIVER_READY_CMD = 0x06,
	WAIT_ENABLE_CMD = 0x07,
	WAIT_RUN_CMD = 0x0f
} dm556_control_cmd_t;

typedef struct {
    uint16_t motor_resolution;
    uint32_t profile_velocity;
	uint32_t end_velocity;
	uint32_t profile_acceleration;
	uint32_t profile_deceleration;
} s_profile_position_config;


int32_t enable_dm556(const can_node_id_t *node_id);
int32_t profile_position_config(const can_node_id_t *node_id, s_profile_position_config *p_position_config);
int32_t profile_velocity_config(const can_node_id_t *node_id, uint16_t motor_resolution,
											uint32_t profile_acceleration, uint32_t profile_deceleration);
int32_t relative_position_move(const can_node_id_t *node_id, int32_t target_position);
int32_t set_spin_direction(const can_node_id_t *node_id, uint32_t dir);
int32_t set_target_velocity(const can_node_id_t *node_id, int32_t target_velocity);
int32_t set_deceleration(const can_node_id_t *node_id, uint32_t deceleration);
int32_t quick_stop(const can_node_id_t *node_id);
int32_t slow_down(const can_node_id_t *node_id, uint32_t deceleration);
int32_t clear_slow_down(const can_node_id_t *node_id);

int32_t set_firEN_func(const can_node_id_t *node_id, u8 state);
int32_t set_firTime_func(const can_node_id_t *node_id, u16 time);


#ifdef __cplusplus
}
#endif


#endif

